<!--# include virtual="/admin/common/html/header.html"-->

<body>
	<article class="page-container">
		<form class="form form-horizontal" id="form-article-add" action="/guidance_service/front/policies/authors/add.do">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span> 发文机关名称：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="hidden" class="input-text" value="" placeholder="" id="authorsId" name="authorsId" disabled="true">
					<input type="text" class="input-text" value="" placeholder="" id="authorsName" name="authorsName">
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
					<button onClick="article_save_submit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存并提交审核</button>
					<button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
				</div>
			</div>
		</form>
	</article>

	<!--# include virtual="/admin/common/html/_footer.html"-->
	<script type="text/javascript">
		function GetQueryString(name){
		     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		     var r = window.location.search.substr(1).match(reg);
		     if(r!=null)return  unescape(r[2]); return null; 
		}
		
		var value=$(window.parent.document).find("#exampleId").val();
		console.log(" 子页面  "+value);
		$(function() {

			if(value != "") {
				
				$.post("/guidance_service/front/policies/authors/get.do", {"authorsId": value}, function(result) {
					if(result.resultCode == 200) {
						$("input[name='authorsId']").attr("disabled",false);
						$("input[name='authorsId']").val(result.data.authorsId);
						$("input[name='authorsName']").val(result.data.authorsName);
					} else {
						layer.msg(result.message, {icon: 2,time: 2000});
					}
				});
			}
		});

		$(function() {

			$('.skin-minimal input').iCheck({
				checkboxClass: 'icheckbox-blue',
				radioClass: 'iradio-blue',
				increaseArea: '20%'
			});

			//表单验证
			$("#form-article-add").validate({
				rules: {
					authorsName: {
						required: true,
					}
				},
				onkeyup: false,
				focusCleanup: true,
				success: "valid",
				submitHandler: function(form) {
					if(value != "") {
						$("#form-article-add").attr("action", "/guidance_service/front/policies/authors/update.do");
						console.log(form.action);
					}
					var data = $(form).serialize();
					console.log('data=' + data);
					$.post(form.action, data, function(result) {
						if(result.resultCode == 200) {
							layer.msg(result.message, {icon: 1,time: 2000}, function() {
								window.parent.location.href = "/admin/modules/policy/authors.html";
							});
						} else {
							layer.msg(result.message, {icon: 2,time: 2000});
						}
					});
				}
			});
		});
	</script>
</body>

</html>